package com.v2.k45;


import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 测试自动注入
 * 2.1 XML中的自动驻入
 *         2.1.1 set方法   byType取的是setP1(Person p)方法的 参数类型Person 所对应的的bean；
 *         				  byName取得是setP1(Person p)方法的 方法名去掉set的名字 ,所以去找名字是p1的bean  P会小写
 *         2.1.2 构造方法  讲推断构造方法时候讲
 */
public class Test {

	public static void main(String[] args) {

		ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring-k45.xml");
		Student student = (Student) applicationContext.getBean("ss1");
		System.out.println(student);
		System.out.println(student.p1);
		System.out.println("------------");
		Student student2 = (Student) applicationContext.getBean("ss2");
		System.out.println(student2);
		System.out.println(student2.p1);
		System.out.println("------------");
//		Student student3 = (Student) applicationContext.getBean("ss3");
//		System.out.println(student3);
//		System.out.println(student3.p1);
//		System.out.println(student3.p2);



	}

}
